package com.upf1sh.controller;

import com.alibaba.fastjson.JSONObject;
import com.upf1sh.bean.FixedPointRobot;
import com.upf1sh.mapper.FixedRobotMapper;
import com.upf1sh.utils.Result;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/fixedpointrobot")
public class FixedPointRobotController {
    @Resource
    private FixedRobotMapper fixedRobotMapper;

    @RequestMapping("/insertOne")
    public void insertOne(@RequestBody JSONObject FixedPointRobot) {
        FixedPointRobot robot1 = JSONObject.parseObject(FixedPointRobot.toJSONString(), FixedPointRobot.class);

        fixedRobotMapper.insert(robot1);
    }

//    public int insert(@RequestBody JSONObject robot) {
//        Robot robot1 = JSONObject.parseObject(robot.toJSONString(), Robot.class);
//        return topicOneService.insert_one(robot1) == 1 ? 1 : 0;
//    }

    @RequestMapping("/selectAll")
    public Result selectAll() {
        return Result.ok().data("data", fixedRobotMapper.selectList(null));
    }

}
